import echarts from "echarts";
import { options } from "runjs";

export function testOp () {
  let option = {
    title: {
      text: "某站点用户访问来源",
      subtext: "纯属虚构",
      x: "center",
    },
    tooltip: {
      trigger: "item",
      formatter: "{a} <br/>{b} : {c} ({d}%)",
    },
    legend: {
      orient: "vertical",
      left: "left",
      data: ["直接访问", "邮件营销", "联盟广告", "视频广告", "搜索引擎"],
    },
    series: [
      {
        name: "访问来源",
        type: "pie",
        radius: "55%",
        center: ["50%", "60%"],
        data: [
          { value: 335, name: "直接访问" },
          { value: 310, name: "邮件营销" },
          { value: 234, name: "联盟广告" },
          { value: 135, name: "视频广告" },
          { value: 1548, name: "搜索引擎" },
        ],
        itemStyle: {
          emphasis: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)",
          },
        },
      },
    ],
  };


return option;
};


export function homeMapChart (dataList) {

  let option = {
    title: {
      text: "云商竞购日活用户分布",
      left: "center",
      top: 20,
      textStyle: {
        color: "#808080",
      },
    },
    tooltip: {
      triggerOn: "mousemove",
      formatter: function (e, t, n) {
        if (isNaN(e.value)) {
          return ".5" == e.value
          ? e.name + ""
          : e.seriesName + "<br />" + e.name + "：0" ;
        } else {
          return ".5" == e.value
          ? e.name + ""
          : e.seriesName + "<br />" + e.name + "：" +e.value;
        }

      },
    },

    visualMap: {
      //左边的图标
      min: 0,
      max: 100000,
      left: 26,
      bottom: '20%',
      showLabel: !0,
      // text: ["高", "低"],
      pieces: [
        {
          gt: 500,
          label: "> 500人",
          color: "#7f1100",
        },
        {
          gte: 200,
          lte: 500,
          label: "200 - 500人",
          color: "#ff5428",
        },
        {
          gte: 100,
          lt: 200,
          label: "100 - 200人",
          color: "#ff8c71",
        },
        {
          gt: 1,
          lt: 100,
          label: "1 - 100人",
          color: "#ffd768",
        },

      ],
      show: !0,
    },

    geo: {
      map: "china",
      top: '10%', //组件离容器上方的距离
      left:'25%',
      // right:'20%',
      bottom:'25%',
      // center: [105.97, 30.71],
      roam: !1,
      scaleLimit: {
        //通过鼠标控制的缩放
        min: 1,
        max: 2,
      },
      zoom: 1.0, //当前缩放比例
      label: {
        normal: {
          show: !0,
          fontSize: "14",
          color: "rgba(0,0,0,0.7)",
        },
      },
      itemStyle: {
        normal: {
          //shadowBlur: 50,
          //shadowColor: 'rgba(0, 0, 0, 0.2)',
          borderColor: "rgba(0, 0, 0, 0.5)",
        },
        emphasis: {
          areaColor: "#f2d5ad", //鼠标放上去的颜色
          shadowOffsetX: 0,
          shadowOffsetY: 0,
          borderWidth: 0,
        },
      },
    },
    series: [
      {
        name: "用户数",
        type: "map",
        geoIndex: 0,
        data: dataList,
      },
    ],
  };


  return option;
};




